#include<bits/stdc++.h>
#define rg register
#define file(x)freopen(x".in","r",stdin);freopen(x".out","w",stdout)

using namespace std;

const int maxn=1e2+10;
const int maxT=1e6+10;

int H,W,n;
char T[maxT];
char S[maxn][maxn];

int main(int argc,char **argv)
{
	auto fin=fopen(argv[1],"r");
	auto fout=fopen(argv[2],"r");
	fscanf(fin,"%d",&n);
	fscanf(fin,"%s",T+1);
	fscanf(fout,"%d %d",&H,&W);
	if(max(H,W)>100)
	{
		fprintf(stderr,"Error");
		exit(1);
	}
	for(rg int i=1;i<=H;i+=1)
		fscanf(fout,"%s",S[i]+1);
	int x,y;fscanf(fout,"%d %d",&x,&y);
	auto check=[&](int id,int x,int y)
			   {
				   if(x<1||x>H||y<1||y>W)
				   {
					   fprintf(stderr,"%d %d\n",x,y);
					   exit(1);
				   }
				   if(S[x][y]!=T[id])
				   {
					   fprintf(stderr,"%d (%d,%d)\n",id,x,y);
					   exit(1);
				   }
				   return;
			   };
	check(1,x,y);
	static char dir[maxn];
	fscanf(fout,"%s",dir+2);
	for(rg int i=2;i<=n;i+=1)
	{
		if(dir[i]=='L')y-=1;
		if(dir[i]=='R')y+=1;
		if(dir[i]=='U')x-=1;
		if(dir[i]=='D')x+=1;
		check(i,x,y);
	}
	return 0;
}
